home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 6 / MacMania 6.toast / / Multimedia & Desktop / sk8 / SK8InJava / Code / Devices / FileTester.java next >
Encoding:
Java Source  |  1996-09-04  |  1.3 KB  |  59 lines  |  [TEXT/CWIE]

  1. /*
  2.    collection tester
  3.     
  4.   */
  5.   
  6. import java.awt.*;
  7. import java.applet.*;
  8.  
  9.  
  10.   
  11.   public class FileTester extends Applet {
  12.       protected boolean mTest;
  13.   
  14.   
  15.       public void init () {
  16.           test();
  17.       }
  18.       
  19.       public void  test() {
  20.           Object obj;
  21.           String s;
  22.           try {
  23.               SK8File testDir = new SK8File ("/Dream Police/");
  24.               SK8File testFile = new SK8File ("/Dream Police/test file");
  25.               
  26.               System.out.println("testing file " + testDir);
  27.               
  28.               if (testDir.fileexists()) 
  29.                   System.out.println("Dream Police exists.  CORRECT");
  30.               else
  31.                   System.out.println("Dream Police does NOT exist.  INCORRECT");
  32.  
  33.               if (testDir.isdirectory()) 
  34.                   System.out.println("Dream Police is a directory.  CORRECT");
  35.               else
  36.                   System.out.println("Dream Police is NOT a directory.  INCORRECT");
  37.                   
  38.               System.out.println("files:  " + testFile.filenames());
  39.               
  40.               System.out.println("testing streams into " + testFile);
  41.               
  42.               String str = new String ("Hello cruel world");
  43.               
  44.  
  45.               SK8TextStream stream = new SK8TextStream ( );
  46.               stream.set_file(testFile);
  47.               
  48.               stream.set_direction("output");
  49.               stream.writestring(str);
  50.               
  51.               stream.close();
  52.               
  53.               
  54.           }
  55.           catch (Exception e) {
  56.                 System.out.println(">> Error!" + e);
  57.           }    
  58.       }
  59. }